package controllers;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import models.Member;
import play.cache.Cache;
import play.data.validation.Error;
import play.data.validation.Valid;
import play.mvc.Controller;
import play.mvc.Scope.Params;

public class Register extends Controller {

	public static void index() {

		render();
	}

	public static void regis(@Valid Member member) {

		validation.equals(params.get("member.retypedemail"),member.loginemail).key("member.retypedemail").message("两次输入的邮箱不一致");
		validation.equals(member.password, params.get("member.retypedpassword")).key("member.retypedpassword").message("两次输入的密码不一致");
		
		
		if (validation.hasErrors()) {
			params.flash(); // add http parameters to the flash scope
			validation.keep(); // keep the errors for the next request
			index();
		} else {

			member.dateTime=new Timestamp(System.currentTimeMillis());
			member.save();

			session.put("memberid", member.id);
			
		}

		render(member);

	}



}
